/*   **********************************************************************  **
 **   Copyright notice                                                       **
 **                                                                          **
 **   (c) 2009, Around(J2)ME				                                 **
 **   All rights reserved.                                                   **
 **                                                                          **
 **   This program and the accompanying materials are made available under   **
 **   the terms of the New BSD License which accompanies this    			 **
 **   distribution.											                 **
 **   A copy is found in the textfile LICENSE.txt							 **
 **                                                                          **
 **   This copyright notice MUST APPEAR in all copies of the file!           **
 **                                                                          **
 **   Main developers:                                                       **
 **     Juri Strumpflohner		http://blog.js-development.com	             **
 **		Matthias Braunhofer		http://matthias.jimdo.com                    **
 **                                                                          **
 **  **********************************************************************  */

package com.aroundj2me.unittests.tests;

import j2meunit.framework.Test;
import j2meunit.framework.TestCase;
import j2meunit.framework.TestMethod;
import j2meunit.framework.TestSuite;

import com.aroundj2me.executableTasks.ContinentRetriever;
import com.aroundj2me.model.TaskProcessListener;

public class PlacesRetrieverTest extends TestCase {
	private String serverURL = "http://localhost:8080/aroundJ2ME/server";
	private ContinentRetriever continentRetriever = null;
	
	
	public PlacesRetrieverTest(String name, TestMethod method) {
		super(name, method);
	}

	public PlacesRetrieverTest() {
	}
	
	protected void setUp() throws Exception {
		continentRetriever = new ContinentRetriever(serverURL);

	}

	protected void tearDown() throws Exception {
		continentRetriever = null;
	}
	
	public void testRetrievePlaces(){
		String continent = "Europe";
		continentRetriever.setContinent(continent);
		continentRetriever.setListener(new TaskProcessListener(){

			public void onError(String status) {
				fail(status);				
			}

			public void taskFinished(Object result) {
				assertNotNull(result);
			}
			
		});
		
		continentRetriever.run();
	}
	
	
	public Test suite() {
		TestSuite suite = new TestSuite();
		suite.addTest(new PlacesRetrieverTest("PlacesRetrieverTest:testRetrievePlaces", new TestMethod() {
			public void run(TestCase tc) {
				((PlacesRetrieverTest) tc).testRetrievePlaces();
			}
		}));
		return suite;
	}
}
